package leetcode.weekly.week301;

import java.util.PriorityQueue;

public class SmallestInfiniteSet {

	int start;
	PriorityQueue<Integer> queue;

	public SmallestInfiniteSet() {
		queue = new PriorityQueue<>();
		start = 1;
	}

	public int popSmallest() {
		if (!queue.isEmpty()) {
			return queue.poll();
		}
		return start++;
	}

	public void addBack(int num) {
		if (num < start && !queue.contains(num)) {
			queue.add(num);
		}
	}
}
